#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[10005];

signed main() {
	int n;
	cin >> n;

	int sum = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i], sum += a[i];

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] < sum / n) {
			ans++;
			a[i + 1] -= sum / n - a[i];
			a[i] = sum / n;
		}
		if (a[i] > sum / n) {
			ans++;
			a[i + 1] += a[i] - sum / n;
			a[i] = sum / n;
		}
	}
	cout << ans;
	return 0;
}
